Containers in OpenStack by Pradeep Kumar Singh
Uploading an image to Swift
We will try to upload an image to Swift. First, check the account details:
$ openstack object store account show +------------+---------------------------------------+ | Field | Value | +------------+---------------------------------------+ | Account | AUTH_8ef89519b0454b57a038b6f044fa0101 | | Bytes | 0 | | Containers | 0 | | Objects | 0 | +------------+---------------------------------------+
We will create an images container to store all our images. Similarly, we can create multiple containers inside an account with any logical name to store different types of data:
$ openstack container create images +---------------------------------------+-----------+------------------------------------+ | account | container | x-trans-id | +---------------------------------------+-----------+------------------------------------+ | AUTH_8ef89519b0454b57a038b6f044fa0101 | images | tx3f28728ccbbe4fcabfe1b-0059b3af9b | +---------------------------------------+-----------+------------------------------------+ $ openstack container list +--------+ | Name | +--------+ | images | +--------+
Now that we have a container, let's upload an image to the container:
$ openstack object create images sunrise.jpeg +--------------+-----------+----------------------------------+ | object | container | etag | +--------------+-----------+----------------------------------+ | sunrise.jpeg | images | 243f98a9d31d140bb123e56624703106 | +--------------+-----------+----------------------------------+ $ openstack object list images +--------------+ | Name | +--------------+ | sunrise.jpeg | +--------------+ $ openstack container show images +--------------+---------------------------------------+ | Field | Value | +--------------+---------------------------------------+ | account | AUTH_8ef89519b0454b57a038b6f044fa0101 | | bytes_used | 2337288 | | container | images | | object_count | 1 | +--------------+---------------------------------------+
You can see that the image was successfully uploaded to the Swift object store.
There are many more features that are available in OpenStack, which you can read about in the user guides available for each project.